using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input.Touch;

namespace SPGE
{
    public abstract class AScene : GameItemContainer, IScene
    {
        public string Name { get; private set; }
        public bool IsDone { get; protected set; }
        public abstract string LoadGroup { get; }

        public bool IsLoaded
        { get { return GameContainer.CurrentContainer.ResourceGroups.IsLoaded(this.LoadGroup); } }

        public AScene(string name)
        {
            Name = name;
        }

        public AScene(string name, Func<IEnumerable<IGameItem>> getItems)
            :base(getItems)
        {
            Name = name;
        }

        public IScene GetNextScene()
        {
            if (!IsDone)
                throw new Exception("Error in Navigation");
            else
                return GetNext();

        }

        public virtual void Update(GameTime gameTime)
        {
            //BaseUpdate(gameTime);
        }

        public virtual void SetEnabledGestures()
        {
            // enable the gestures we care about. you must set EnabledGestures before
            // you can use any of the other gesture APIs.
            // we use both Tap and DoubleTap to workaround a bug in the XNA GS 4.0 Beta
            // where some Taps are missed if only Tap is specified.
            TouchPanel.EnabledGestures =
                GestureType.Tap |
                GestureType.DoubleTap;
        }

        protected abstract IScene GetNext();

        public override void Initialize()
        {
            base.Initialize();

            SetEnabledGestures();
        }

    }
}
